package com.igeek.d0611.test1;

/**
 * @Author: zhiyu
 * @Date:17:32
 * @DESC:
 */
public class T_runnable {
    public static void main(String[] args) {
        RunnableDemo runnableDemo = new RunnableDemo();
        Thread thread = new Thread(runnableDemo, "线程1");
        thread.start();
        System.out.println("===============匿名内部类===================");
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName() + ":i=" + i);
                }
            }
        }, "线程2").start();
        System.out.println("==================lambda=================");
        new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName() + ":i=" + i);
            }
        }, "线程3").start();
    }
}

class RunnableDemo implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + ":i=" + i);
        }
    }
}